//
//  JKRMainViewController.m
//  YYKitTest
//
//  Created by tronsis_ios on 16/7/13.
//  Copyright © 2016年 tronsis_ios. All rights reserved.
//

#import "JKRMainViewController.h"
#import "JKRNavigationController.h"
#import "JKRHomeViewController.h"
#import "JKRMeViewController.h"

@implementation JKRMainViewController

+ (void)initialize {
    UITabBar *bar = [UITabBar appearanceWhenContainedInInstancesOfClasses:@[[JKRMainViewController class]]];
    bar.tintColor = UIColorHex(fd8224);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self _initView];
    [self _setChildViewControllers];
}

- (void)_initView {
    
}

- (void)_setChildViewControllers {
    [self _addChildViewController:[JKRHomeViewController new] title:@"Home" image:[UIImage imageNamed:@"tabbar_home"] selectedImage:[UIImage imageNamed:@"tabbar_home_highlighted"]];
    [self _addChildViewController:[JKRMeViewController new] title:@"Me" image:[UIImage imageNamed:@"tabbar_profile"] selectedImage:[UIImage imageNamed:@"tabbar_profile_highlighted"]];
}

- (void)_addChildViewController:(nonnull __kindof UIViewController *)childController title:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage {
    childController.tabBarItem.image = image;
    childController.tabBarItem.selectedImage = selectedImage;
    childController.title = title;
    [self addChildViewController:JKRUINavigationController(childController)];
}

static inline UINavigationController *JKRUINavigationController(UIViewController *rootViewController) {
    return [[JKRNavigationController alloc] initWithRootViewController:rootViewController];
}

@end
